package supremeragcalc.util.gui;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JPanel;

public class RagImagePanel extends JPanel {

	private Image img;

	public RagImagePanel() {
		setLayout(null);
		Dimension size = new Dimension(1, 1);
		setPreferredSize(size);
		setMinimumSize(size);
		setMaximumSize(size);
	}

	public RagImagePanel(String path) {
		this();
		setImage(path);
	}

	public Image getImage() {
		return img;
	}

	public void setImage(String path) {
		//System.out.println(System.getProperty("user.dir"));
		GenericImage gi = new GenericImage(path);
		img = gi.getImage();
		
		Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
		setPreferredSize(size);
		setMinimumSize(size);
		setMaximumSize(size);
		repaint();
	}

	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		g.drawImage(img, 0, 0, null);
	}
}
